package com.kma.summer2012.client.view.viewmap;


import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.datepicker.client.DatePicker;
import com.kma.summer2012.client.presenters.viewmap.ViewMapPresenter;
import com.kma.summer2012.client.styles.style2.Recources;

import java.util.Date;

public class ViewMap extends Composite implements ViewMapPresenter.Display {
    interface ViewMapUiBinder extends UiBinder<Widget, ViewMap> {
    }

    private static ViewMapUiBinder uiBinder = GWT.create(ViewMapUiBinder.class);

    public ViewMap() {
        HTMLPanel rootElement = (HTMLPanel) uiBinder.createAndBindUi(this);
        backButton.addStyleName(Recources.INSTANCE.styles().Caption());
        textLabel.setStyleName(Recources.INSTANCE.styles().lable());
        calendar.setValue(new Date(), true);
        panel.add(table2);
        panel.add(calendar);
        initWidget(rootElement);
    }

    @UiField
    HorizontalPanel panel;

    @UiField
    DatePicker calendar;

    @UiField
    Label dateLabel;

    @UiField
    Label textLabel;

    //@UiField
    MyTable table2 = new MyTable();

    @UiField
    Button backButton;


    @Override
    public MyTable getViewMapTable() {
        return this.table2;
    }

    @Override
    public String getCellStyleName(int row, int column) {
        return table2.getCellFormatter().getStyleName(row, column);
    }

    @Override
    public void setCellStyleName(int row, int column, String name) {
        table2.getCellFormatter().setStyleName(row, column, name);
    }


    @Override
    public Date getDateFromCalendar() {
        return this.calendar.getValue();
    }

    @Override
    public DatePicker getCalendar() {
        return this.calendar;
    }

    @Override
    public void setDateLabel(String date) {
        dateLabel.setText(date);
    }

    @Override
    public Button getBackButton() {
        return backButton;
    }

    @Override
    public Widget asWidget() {
        return this;
    }

}